PACKAGE	= puzzattack
VERSION	= 0.01

PREFIX	= /usr/local
BINDIR	= ${PREFIX}/bin
DOCDIR	= ${PREFIX}/share/doc/${PACKAGE}
SRCDIR	= ${PREFIX}/lib/${PACKAGE}

SRC	= ${PACKAGE}.c
OBJ	= ${SRC:.c=.o}

CFLAGS	= -Wall -DVERSION=\"${VERSION}\" -DSRCDIR=\"${SRCDIR}\" `sdl-config --cflags`
LDFLAGS	= `sdl-config --libs`

all: ${PACKAGE}

.c.o:
	@echo CC $<
	@${CC} -c ${CFLAGS} $<

${PACKAGE}: ${OBJ}
	@echo CC $<
	@${CC} -o $@ ${OBJ} ${LDFLAGS}

dist: clean
	@mkdir -p ${PACKAGE}-${VERSION}
	@cp -R bmp Makefile README LICENSE ${PACKAGE}.c ${PACKAGE}-${VERSION}
	@tar -cf ${PACKAGE}-${VERSION}.tar ${PACKAGE}-${VERSION}
	@gzip ${PACKAGE}-${VERSION}.tar
	@rm -rf ${PACKAGE}-${VERSION}
	@echo created ${PACKAGE}-${VERSION}.tar.gz

install: all
	@mkdir -p ${BINDIR}
	@mkdir -p ${DOCDIR}
	@mkdir -p ${SRCDIR}

	@install -d ${BINDIR} ${SRCDIR} ${DOCDIR}
	@install -m 644 README LICENSE ${DOCDIR}
	@install -m 775 ${PACKAGE} ${BINDIR}
	@install -m 644 bmp/* ${SRCDIR}
	@echo installed ${PACKAGE}

uninstall:
	@rm -rf ${SRCDIR}
	@rm -rf ${DOCDIR}
	@rm -r ${BINDIR}/${PACKAGE}
	@echo uninstalled ${PACKAGE}

clean:
	@rm -f ${PACKAGE} *.o
